<?php
defined('EXEC') or die();

$form 			= false;
$rowEdit 		= array();
$table 			= 'tethys.tb_titulos tt inner join tethys.tb_fornecedor tp on tp.ci_fornecedor=tt.cd_pessoa inner join tethys.tb_tipo_documento td on tt.cd_tipo_documento=td.ci_tipo_documento';
$updateTable    ='tethys.tb_titulos';
$tablepk 		= 'ci_titulo';
$cd_titulos     = $_GET["cd_titulo"];
$fields=" tt.ci_titulo, td.nm_tipo_documento||'-'||tt.nr_documento as nm_documento,
	   td.ci_tipo_documento, td.nm_tipo_documento,tt.nr_documento as nr_documento,  tp.ci_fornecedor,
       tp.nm_fornecedor,  to_char(tt.dt_cadastro,'dd/mm/yyyy') as dt_cadastro,
       to_char(tt.dt_emissao,'dd/mm/yyyy') as dt_emissao, to_char(tt.dt_vencimento,'dd/mm/yyyy') as dt_vencimento,
       tt.vlr_documento,  tt.vlr_pago, tt.multa,tt.juros, tt.desconto, tt.tipo_titulo,tt.obs";

//Adicionando js para picklist
Controller::addHead('jquery.picklists', 'js');
Controller::addHead('jquery.multiselects-0.3', 'js');

//getRowsByFields($table, $where=null, $otherWhere=null, $fetch=false, $start=0, $offset=0, $fields=null, $order=null)
//carregando os valores do titulo selecionado
$rowEdit = SQL::getRowsByFields($table, array($tablepk => $_GET['form']), null,  true, null, null, $fields, null);


?>
<div id="container">
	<table border="0" align="center">
		<tr>
			<td></td>
			<td><div class="validateTips"></div></td>
		</tr>
		<tr>
			<td align="right">Fornecedor:*</td>
		</tr>
		<tr>
			<td align="right">Emissão:*</td>
			<td><input type="text" id="dt_emissao" name="dt_emissao"
				value="<?php echo trim(@$rowEdit['dt_emissao']); ?>"
				onkeypress="mask(this, maskData)"
				class="text ui-widget-content ui-corner-all" style="width: 100px"
				maxlength="10" /> &nbsp;Vencimento:<input type="text"
				id="dt_vencimento" name="dt_vencimento"
				value="<?php echo trim(@$rowEdit['dt_vencimento']); ?>"
				onkeypress="mask(this, maskData)"
				class="text ui-widget-content ui-corner-all" style="width: 100px"
				maxlength="10" /></td>
		</tr>
		<tr>
			<td align="right">Valor:*</td>
			<td><input type="text" id="vlr_documento" name="vlr_documento"
				value="<?php echo trim(@$rowEdit['vlr_documento']); ?>"
				class="text ui-widget-content ui-corner-all" style="width: 150px"
				maxlength="90" /> &nbsp;Multa<input type="text" id="multa"
				name="multa" class="text ui-widget-content ui-corner-all"
				value="<?php echo trim(@$rowEdit['multa']); ?>" style="width: 150px"
				maxlength="90" /></td>
		</tr>
		<tr>
			<td align="right">Juros:*</td>
			<td><input type="text" id="juros" name="juros"
				class="text ui-widget-content ui-corner-all"
				value="<?php echo trim(@$rowEdit['juros']); ?>" style="width: 150px"
				maxlength="90" /> &nbsp;Desconto:<input type="text" id="desconto"
				name="desconto" class="text ui-widget-content ui-corner-all"
				value="<?php echo trim(@$rowEdit['desconto']); ?>"
				style="width: 150px" maxlength="90" /></td>
		</tr>
		<tr>
			<td colspan="2">Obs: <textarea name="obs" id="obs" rows="3"
					cols="100">
					<?php echo trim(@$rowEdit['obs']); ?>
				</textarea></td>
		</tr>
		<tr>
		
		
		<tr>
			<td></td>
			<td><button id="btInsertEdit" type="submit">
			<?php echo $btFormLabel; ?>
				</button></td>
		</tr>
	</table>
</div>
